#include <bits/stdc++.h>
using namespace std;

struct car
{
    int d, v, a, id;
    car() {}
    car(int d, int v, int a, int id)
    {
        this->d = d;
        this->v = v;
        this->a = a;
        this->id = id;
    }

    int get_speed_after_t(int t)
    {
        return v + a * t;
    }
    int get_pos_change(int t)
    {
        return v * t + 0.5 * a * t * t;
    }
    int get_now_speed(int t)
    {
        return sqrt(v * v + 2 * a * get_pos_change(t));
    }
    int get_now_pos(int t)
    {
        return d + get_pos_change(t);
    }
};

void solve()
{
    // variables define
    int n, m, L, V, _d, _v, _a, res = 0, x;
    vector<car> cars;
    bool det[(int)1e6+5];
    memset(det, false, sizeof(det));
    set<int> st;
    
    // input
    scanf("%d %d %d %d", &n, &m, &L, &V);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d", &_d, &_v, &_a);
        cars.push_back(car(_d, _v, _a, i + 1));
    }
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        det[x] = true;
    }

    // main do
    for (car c : cars)
    {
        int t = 0;
        while (c.get_now_speed(t) > 0 && c.get_now_pos(t) <= L)
        {
            if (c.get_now_speed(t) > V && det[c.get_now_pos(t)])
            {
                res++;
                st.insert(c.get_now_pos(t));
                t++;
                break;
            }
            t++;
        }
    }

    // output
    printf("%d %d\n", res, n - st.size());
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    scanf("%d", &T);
    while (T--)
        solve();
    return 0;
}